package com.serviceprovider.business.module.order.services.impl;

//~--- non-JDK imports --------------------------------------------------------

import com.serviceprovider.business.module.order.model.OrderAttribute;
import com.serviceprovider.business.module.order.services.dao.interfaces.IOrderAttributeDao;
import com.serviceprovider.business.module.order.services.interfaces.IOrderSettingsService;
import com.serviceprovider.business.module.order.valueobjects.OrderAttributeVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//~--- JDK imports ------------------------------------------------------------

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderSettingsServiceImpl implements IOrderSettingsService {
    @Autowired
    private IOrderAttributeDao orderAttributeDao;

    @Override
    public List<OrderAttributeVO> findAll() {
        List<OrderAttributeVO> result = new ArrayList<OrderAttributeVO>();
        List<OrderAttribute>   list   = orderAttributeDao.findAll();

        for (OrderAttribute item : list) {
            result.add(new OrderAttributeVO(item));
        }

        return result;
    }

    @Override
    public void addNew(OrderAttributeVO orderAttribute) {
        orderAttributeDao.createNew(new OrderAttribute(orderAttribute));
    }

    @Override
    public OrderAttributeVO getById(Integer id) {
        OrderAttribute orderAttribute = orderAttributeDao.getById(id);

        return new OrderAttributeVO(orderAttribute);
    }

    @Override
    public void update(OrderAttributeVO orderAttribute) {
        orderAttributeDao.update(new OrderAttribute(orderAttribute));
    }

    @Override
    public void removeById(Integer id) {
        orderAttributeDao.removeById(id);
    }
}



